/*
 * @Author: linxun 
 * @Date: 2021-03-12 14:48:07 
 * @Last Modified by: linxun
 * @Last Modified time: 2021-03-31 15:13:15
 * @Description: 数据处理
 */

import React, { useEffect } from 'react';
import { Modal, Form, Checkbox } from 'antd';
import { useIntl } from 'umi';

const FormItem = Form.Item;

const commonLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 16 },
};

const DataProssingModal = props => {
  const [form] = Form.useForm();
  const { formatMessage } = useIntl();
  const { visible, cancel, loading, onSubmit, curRecord } = props;

  const onOk = () => {
    form.validateFields().then(values => {
      onSubmit(values);
    }).catch(err => {
      console.log(err);
    });
  };

  return (
    <Modal
      title={`${curRecord.name}-抠图`}
      visible={visible}
      onCancel={cancel}
      confirmLoading={loading}
      onOk={onOk}
      maskClosable={false}
      forceRender
      width={800}
      afterClose={() => form.resetFields()}
    >
      <Form form={form} scrollToFirstError {...commonLayout}>
        <FormItem
          name='labels'
          label='选择标签'
          rules={[{ required: true, message: '请选择标签' }]}
          extra='点击下面数据集标注标签，选中后将会自动按标注标签进行扣图并创建以该标签命名的新数据集'
        >
          <Checkbox.Group>
            {curRecord.labelList?.map(item => (
              <Checkbox key={item} value={item}>{item}</Checkbox>
            ))}
          </Checkbox.Group>
        </FormItem>
      </Form>
    </Modal>
  )
}

export default DataProssingModal;